package br.infotec.deptmusica.diasemana;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import br.infotec.deptmusica.fila.Fila;

@Entity
@Table(name = "dia_semana")
public class DiaSemana implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2130798072760417347L;
	
	@Id
	@GeneratedValue
	@Column(name = "id_dia_semana")
	private Integer idDiaSemana;
	@Column( name = "dia_semana")
	private String diaSemana;
	
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "dia_semana_has_fila", joinColumns = { @JoinColumn(name = "id_dia_semana") },
				inverseJoinColumns = { @JoinColumn(name = "id_fila") })
	private List<Fila> fila;
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((diaSemana == null) ? 0 : diaSemana.hashCode());
		result = prime * result
				+ ((idDiaSemana == null) ? 0 : idDiaSemana.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DiaSemana other = (DiaSemana) obj;
		if (diaSemana == null) {
			if (other.diaSemana != null)
				return false;
		} else if (!diaSemana.equals(other.diaSemana))
			return false;
		if (idDiaSemana == null) {
			if (other.idDiaSemana != null)
				return false;
		} else if (!idDiaSemana.equals(other.idDiaSemana))
			return false;
		return true;
	}
	
	public Integer getIdDiaSemana() {
		return idDiaSemana;
	}
	public void setIdDiaSemana(Integer idDiaSemana) {
		this.idDiaSemana = idDiaSemana;
	}
	public String getDiaSemana() {
		return diaSemana;
	}
	public void setDiaSemana(String diaSemana) {
		this.diaSemana = diaSemana;
	}
	public List<Fila> getFila() {
		return fila;
	}
	public void setFila(List<Fila> fila) {
		this.fila = fila;
	}
}
